package HashBuck;

import java.util.Objects;

class Student {
    public String stuN;

    public Student(String stuN) {
        this.stuN=stuN;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(stuN, student.stuN);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(stuN);
    }
}

public class Test {

    public static void main3(String[] args) {
        Student student1=new  Student("1");

        HashBuck2<Student,Double> hashBuck = new HashBuck2<Student,Double>();
        hashBuck.put(student1,99.99);
        Student student2=new  Student("1");

        //以student1存入,以student2取出,但是两者的学号一致,因此取出的应是同一分数
        System.out.println(hashBuck.get(student2));
    }

    public static void main2(String[] args) {
        Student student1=new  Student("1");
        Student student2=new  Student("1");
        int hashcode1=student1.hashCode();
        int hashcode2=student2.hashCode();
        System.out.println(hashcode1);
        System.out.println(hashcode2);
    }

    public static void main(String[] args) {
        HashBuck hb=new HashBuck();
        hb.put(1,11);
        hb.put(4,44);
        hb.put(14,1414);
        hb.put(24,2424);
        hb.put(3,33);
        hb.put(6,66);
        hb.put(7,77);
        hb.put(8,88);
        System.out.println(hb.get(14));
    }
}
